const crypto=require('crypto');


//一
var one=crypto.createDiffieHellman(500);
var one_keys=one.generateKeys();

var prime=one.getPrime();
var generator=one.getGenerator();

console.log("Prime: "+ prime.toString('hex'));
console.log("Generator: "+ generator.toString('hex'));


//二

var two=crypto.createDiffieHellman(prime,generator);
var two_keys=two.generateKeys();

//交换
var one_secret=one.computeSecret(two_keys);
var two_secret=two.computeSecret(one_keys);

console.log("Secret of one: "+one_secret.toString('hex'));
console.log("Secret of two: "+two_secret.toString('hex'));